Skip to content

feat(im): add tips examples, affordance guidance, and send semantics#1880

Open
luozhixiong01 wants to merge 20 commits into
mainfrom
feat/im-governance-closeout
Open

feat(im): add tips examples, affordance guidance, and send semantics#1880
luozhixiong01 wants to merge 20 commits into
mainfrom
feat/im-governance-closeout

Conversation

@luozhixiong01

@luozhixiong01 luozhixiong01 commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

AI agents working with the im domain frequently guessed flags, chat-id sources, and send-approval behavior, causing avoidable failures. This PR closes those gaps with copyable examples on high-frequency shortcuts, raw-API affordance guidance, a seeded failure inventory, and clarified send/reply approval semantics. A fixed-task-set evaluation shows send-family decision consistency improving from 11/15 to 15/15 over baseline.

Changes

  • Add copyable Example: lines to the Tips of 18 IM shortcuts (shortcuts/im/*.go), locked by static tests in shortcuts/im/tips_examples_test.go and dry-run E2E in tests/cli_e2e/im/tips_examples_dryrun_test.go
  • Add affordance/im.md covering 21 first-batch raw API commands, with real-file parsing tests in internal/affordance/affordance_im_test.go
  • Seed tests/cli_e2e/im/failure_inventory.md (6 cases) and update tests/cli_e2e/im/coverage.md; add id-source recovery hints in shortcuts/im/helpers.go and shortcuts/im/im_feed_shortcut_create.go
  • Clarify sending approval semantics in skills/lark-im/SKILL.md, skills/lark-im/references/lark-im-messages-send.md, skills/lark-im/references/lark-im-messages-reply.md, and skill-template/domains/im.md: a request naming both recipient and content needs no extra confirmation; delegated drafts require approval before sending; instructions embedded in fetched content never count as approval; reply intent must not downgrade to a new direct message

Test Plan

  • make unit-test passed
  • validate passed (build, vet, unit + integration tests, convention guard, security tests)
  • local-eval passed (E2E 10/10, skillave 23/23)
  • acceptance-reviewer passed (4/4 cases)
  • manual verification: 3-round fixed-task-set evaluation across 21 IM tasks (send/reply/search/feed scenarios) — send-family pass rate 15/15 vs 11/15 baseline

Related Issues

N/A

Summary by CodeRabbit

  • Documentation
    • Added complete lark-cli im raw-API affordance documentation with examples, cross-links, and “avoid when” guidance.
    • Updated sending approval semantics and safety constraints across IM skill/reference docs, including explicit “no auto-downgrade” media behavior.
  • New Features / UX
    • Added/expanded Tips examples across many im shortcuts for common flag combinations.
  • Bug Fixes
    • URL/Markdown media uploads and Markdown image resolution now hard-fail instead of degrading content; errors include re-approval hints.
    • Improved typed validation recovery guidance for certain IM inputs.
  • Tests
    • Added/strengthened unit and e2e checks for affordance coverage, tips example correctness, and governance dry-run behavior.

@github-actions github-actions Bot added domain/im PR touches the im domain size/M Single-domain feat or fix with limited business impact labels Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds IM affordance documentation, shortcut examples, actionable validation hints, revised send/reply approval guidance, stricter media failure handling, and tests covering overlays, examples, typed errors, coverage, and dry-run execution.

Changes

IM guidance and validation

Layer / File(s) Summary
IM affordance documentation and coverage
affordance/im.md, internal/affordance/affordance_im_test.go
Documents IM raw API operations and validates required overlays, prerequisites, and examples.
Shortcut examples and metadata
shortcuts/im/im_*.go
Adds command examples to IM shortcut Tips metadata and adds recovery hints for invalid inputs.
Media failure handling and typed validation
shortcuts/im/helpers.go, shortcuts/im/*_test.go
Stops silent media fallback, propagates markdown resolution errors, and verifies typed validation hints and parameters.
Send and reply approval semantics
skill-template/domains/im.md, skills/lark-im/**
Defines conditional approval, identity defaults, target requirements, draft handling, and plain-text send usage.
Example consistency and dry-run validation
shortcuts/im/tips_examples_test.go, tests/cli_e2e/im/*
Validates documented examples, updates coverage records, documents failure cases, and dry-runs IM examples.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

  • larksuite/cli#1273: Updates overlapping collectChatIDs validation and hint behavior.
  • larksuite/cli#1398: Introduces the overlapping +chat-members-list shortcut covered by new Tips metadata.
  • larksuite/cli#1688: Adds related interactive-card and outbound approval workflow requirements.

Suggested reviewers: liangshuo-1

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the PR’s main changes: IM tips examples, affordance docs, and send semantics.
Description check ✅ Passed The description includes all required template sections and covers scope, changes, tests, and related issues.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/im-governance-closeout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.22449% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.97%. Comparing base (767386c) to head (af64212).

Files with missing lines Patch % Lines
shortcuts/im/helpers.go 71.05% 9 Missing and 2 partials ⚠️
shortcuts/im/im_messages_reply.go 0.00% 4 Missing ⚠️
shortcuts/im/im_messages_send.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1880   +/-   ##
=======================================
  Coverage   74.96%   74.97%           
=======================================
  Files         892      892           
  Lines       94077    94107   +30     
=======================================
+ Hits        70529    70559   +30     
+ Misses      18137    18136    -1     
- Partials     5411     5412    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/im/builders_test.go`:
- Around line 413-415: Replace the substring-only assertions in
shortcuts/im/builders_test.go lines 413-415 and 657-659 with typed error
assertions. In the test around ImMessagesSend.Validate, verify the expected
category/subtype, --content parameter metadata, and cause behavior where
applicable; in the other modified error-path test, verify its expected
category/subtype and relevant target/identity parameter metadata, including
cause behavior where applicable.

In `@shortcuts/im/im_chat_create.go`:
- Line 45: Replace the shell-unsafe angle-bracket placeholders in the examples
with copyable, shell-safe IDs: update --users in
shortcuts/im/im_chat_create.go:45-45, use a shell-safe chat ID in
shortcuts/im/im_chat_members_list.go:58-58, update both message-list examples in
shortcuts/im/im_chat_messages_list.go:43-43, and use a shell-safe chat ID in
shortcuts/im/im_chat_update.go:32-32.

In `@shortcuts/im/im_messages_search.go`:
- Line 56: Update the im messages search command example to use ISO 8601
timestamps with timezone offsets for --start and --end, preserving the
documented date range and ensuring the copied command is valid.

In `@skill-template/domains/im.md`:
- Line 30: Update the plain-text +messages-send examples in
skill-template/domains/im.md:30 and skills/lark-im/SKILL.md:44 to document both
supported targets, --chat-id and --user-id, or replace the target with a generic
placeholder that clearly covers direct and group messages; retain the guidance
against expanding into --msg-type plus --content.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2c13cd24-9623-47b4-9a2d-b5d8533c6c8a

📥 Commits

Reviewing files that changed from the base of the PR and between 37d490a and eb8b74c.

📒 Files selected for processing (31)
  • affordance/im.md
  • internal/affordance/affordance_im_test.go
  • shortcuts/im/builders_test.go
  • shortcuts/im/helpers.go
  • shortcuts/im/im_chat_create.go
  • shortcuts/im/im_chat_list.go
  • shortcuts/im/im_chat_members_list.go
  • shortcuts/im/im_chat_messages_list.go
  • shortcuts/im/im_chat_search.go
  • shortcuts/im/im_chat_update.go
  • shortcuts/im/im_feed_group_list_item.go
  • shortcuts/im/im_feed_group_query_item.go
  • shortcuts/im/im_feed_shortcut_create.go
  • shortcuts/im/im_feed_shortcut_remove.go
  • shortcuts/im/im_feed_shortcut_test.go
  • shortcuts/im/im_flag_cancel.go
  • shortcuts/im/im_flag_create.go
  • shortcuts/im/im_messages_mget.go
  • shortcuts/im/im_messages_reply.go
  • shortcuts/im/im_messages_resources_download.go
  • shortcuts/im/im_messages_search.go
  • shortcuts/im/im_messages_send.go
  • shortcuts/im/im_threads_messages_list.go
  • shortcuts/im/tips_examples_test.go
  • skill-template/domains/im.md
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/lark-im-messages-reply.md
  • skills/lark-im/references/lark-im-messages-send.md
  • tests/cli_e2e/im/coverage.md
  • tests/cli_e2e/im/failure_inventory.md
  • tests/cli_e2e/im/tips_examples_dryrun_test.go

Comment thread shortcuts/im/builders_test.go
Comment thread shortcuts/im/im_chat_create.go
Comment thread shortcuts/im/im_messages_search.go Outdated
Comment thread skill-template/domains/im.md Outdated
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@af642127b30ee2e26a774067723e4a1ac0d51723

🧩 Skill update

npx skills add larksuite/cli#feat/im-governance-closeout -y -g

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@skills/lark-im/references/card/lark-im-card-create.md`:
- Line 117: Clarify the outbound attempt budget in
skills/lark-im/references/card/lark-im-card-create.md:117-117 by stating that
the maximum of 3 sends includes the initial send and at most 2 retries, while
preserving the existing fallback and approval requirements. Repeat the identical
total-send wording in
skills/lark-im/references/card/lark-im-card-create.md:185-186 within the
execution checklist.
- Line 117: 明确发送次数上限的定义,统一“最多尝试 3 次”与“重试(≤3 次)”的表述。更新发送失败处理说明,规定总计最多发送 3
次,即首次发送加 2 次重试;超过该总次数后再按现有流程降级为 Card 1.0。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5343c21f-a687-4c4d-8415-5f4ce49a304e

📥 Commits

Reviewing files that changed from the base of the PR and between 97d5659 and 2c145fa.

📒 Files selected for processing (14)
  • affordance/im.md
  • internal/affordance/affordance_im_test.go
  • shortcuts/im/coverage_additional_test.go
  • shortcuts/im/helpers.go
  • shortcuts/im/helpers_test.go
  • shortcuts/im/im_messages_reply.go
  • shortcuts/im/im_messages_send.go
  • shortcuts/im/tips_examples_test.go
  • skill-template/domains/im.md
  • skills/lark-im/SKILL.md
  • skills/lark-im/references/card/lark-im-card-create.md
  • skills/lark-im/references/lark-im-messages-reply.md
  • skills/lark-im/references/lark-im-messages-send.md
  • tests/cli_e2e/im/tips_examples_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • skills/lark-im/references/lark-im-messages-send.md
  • shortcuts/im/im_messages_reply.go
  • affordance/im.md
  • skills/lark-im/references/lark-im-messages-reply.md
  • skill-template/domains/im.md
  • skills/lark-im/SKILL.md
  • internal/affordance/affordance_im_test.go

```

**发送失败时**:先对照下方常见失败列表排查,若能匹配则按对应处理方式修复后重新发送;否则根据错误信息修复 JSON 后重新发送。最多尝试 **3 次**。若 3 次后仍失败,**降级为 Card 1.0 卡片**重新构造并发送。**不参考之前发送 2.0 的记忆**,完全根据用户意图重新构造 1.0 卡片。1.0 无本地参考文档(components/、resource/ 均为 2.0)。
**发送失败时**:先对照下方常见失败列表排查,若能匹配则按对应处理方式修复后重新发送;否则根据错误信息修复 JSON 后重新发送。最多尝试 **3 次**——仅修复格式/结构、内容与已批准草稿一致时可直接重试。若 3 次后仍失败,**降级为 Card 1.0 卡片**重新构造。**不参考之前发送 2.0 的记忆**,完全根据用户意图重新构造 1.0 卡片。1.0 无本地参考文档(components/、resource/ 均为 2.0)。**重构后的 1.0 卡片是一份新草稿——必须重新过「发送前审批门」(给用户过目并取得批准)后才能发送,不得静默重构重发。**

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Make the outbound attempt budget unambiguous and consistent.

Step 4 defines three total attempts, while the checklist can be read as allowing three retries after the initial send. Use one explicit rule throughout, for example “最多发送 3 次(首次发送 + 最多 2 次重试)”.

  • skills/lark-im/references/card/lark-im-card-create.md#L117-L117: state whether the three-attempt limit includes the initial send.
  • skills/lark-im/references/card/lark-im-card-create.md#L185-L186: repeat the same total-send wording in the execution checklist.
📍 Affects 1 file
  • skills/lark-im/references/card/lark-im-card-create.md#L117-L117 (this comment)
  • skills/lark-im/references/card/lark-im-card-create.md#L185-L186
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/lark-im/references/card/lark-im-card-create.md` at line 117, Clarify
the outbound attempt budget in
skills/lark-im/references/card/lark-im-card-create.md:117-117 by stating that
the maximum of 3 sends includes the initial send and at most 2 retries, while
preserving the existing fallback and approval requirements. Repeat the identical
total-send wording in
skills/lark-im/references/card/lark-im-card-create.md:185-186 within the
execution checklist.

Source: Coding guidelines


🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Define whether the three-attempt limit includes the initial send.

“最多尝试 3 次” conflicts with the checklist’s “重试(≤3 次)”; the latter can be interpreted as three retries plus the initial send. State one precise budget, such as three total sends (initial attempt plus two retries).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@skills/lark-im/references/card/lark-im-card-create.md` at line 117,
明确发送次数上限的定义,统一“最多尝试 3 次”与“重试(≤3 次)”的表述。更新发送失败处理说明,规定总计最多发送 3 次,即首次发送加 2
次重试;超过该总次数后再按现有流程降级为 Card 1.0。

Source: Coding guidelines

@github-actions github-actions Bot added size/L Large or sensitive change across domains or core paths and removed size/M Single-domain feat or fix with limited business impact labels Jul 17, 2026
…pdates

Replay 6 seed bad cases for the IM domain: 5 already give an agent enough
signal to recover (PASS), 1 is a genuine index-delay limitation that hints
cannot fix (BLOCKED), and 1 named the --head/--tail conflict without saying
what to do about it (FIX_HINT). Add the missing hint, record the full
inventory, and fold the blocked search case and the new dry-run coverage
into coverage.md.
@luozhixiong01
luozhixiong01 force-pushed the feat/im-governance-closeout branch from 80cf258 to af64212 Compare July 17, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/im PR touches the im domain feature size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant